# Maintainer: Laurent Carlier <lordheavym@gmail.com>

pkgname=vulkan-validation-layers
pkgver=1.2.190
pkgrel=1
pkgdesc="Vulkan Validation Layers"
arch=(x86_64)
url="https://www.khronos.org/vulkan/"
license=('custom')
groups=('vulkan-devel')
depends=('gcc-libs' 'vulkan-icd-loader' 'vulkan-headers' 'libx11')
makedepends=('cmake' 'python-lxml' 'libxrandr' 'wayland' 'git')
provides=('libVkLayer_khronos_validation.so')
options=(!strip)
source=("https://github.com/KhronosGroup/Vulkan-ValidationLayers/archive/v${pkgver}.tar.gz")
#source=("git+https://github.com/KhronosGroup/Vulkan-ValidationLayers.git#commit=35d091dad71304dab79758fdae4bda12f692d735")
sha256sums=('87dd51b927f369beb0350d5ac5fcd25aa0e0f7538ee98df08e6726854956f9c0')

#pkgver() {
#  cd "${srcdir}/Vulkan-ValidationLayers"
#
#  echo 1.1.97.0+$(git rev-list --count HEAD)+$(git rev-parse --short HEAD)
#}

prepare() {
  cd "${srcdir}"/Vulkan-ValidationLayers*

  rm -rf build && mkdir build
}

build() {
  cd "${srcdir}"/Vulkan-ValidationLayers*/build

  ../scripts/update_deps.py
  cmake -C helper.cmake \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DCMAKE_INSTALL_SYSCONFDIR=/etc \
    -DCMAKE_INSTALL_DATADIR=/share \
    -DCMAKE_INSTALL_INCLUDEDIR="/usr/include/" \
    -DBUILD_LAYER_SUPPORT_FILES=ON \
    -DCMAKE_SKIP_RPATH=True \
    -DBUILD_TESTS=Off \
    -DBUILD_WSI_XCB_SUPPORT=On \
    -DBUILD_WSI_XLIB_SUPPORT=On \
    -DBUILD_WSI_WAYLAND_SUPPORT=On \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo \
    ..
  make
}

package() {
  cd "${srcdir}"/Vulkan-ValidationLayers*/build
  
  make DESTDIR="${pkgdir}" install

  install -dm755 "${pkgdir}"/usr/share/{licenses/,doc/}${pkgname}/
  cp -r ../docs/* "${pkgdir}"/usr/share/doc/${pkgname}/
  install -m644 ../LICENSE.txt "${pkgdir}"/usr/share/licenses/${pkgname}/
}
